package com.market.plus.core.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@Table(name = "Friend")
public class Friend implements Persistable, ModifyedInfo{

   @Id
   @GeneratedValue(strategy = GenerationType.TABLE, generator = "GEN_FRIEND")
   @TableGenerator(name = "GEN_FRIEND", table = "SEQUENCE_LIST", allocationSize = 1, initialValue = 1, pkColumnName = "NAME", valueColumnName = "NEXT_SEQUENCE", pkColumnValue = "FRIEND")
   @Column(name = "FRIEND_ID")
   private Long id;

   @ManyToOne
   @JoinColumn(name="Friend_Part_ID")
   private Participant friendInfo;

   @ManyToOne
   @JoinColumn(name="Participant_ID")
   private Participant participant;

   @Column(name="RequestedDate")
   private Date requestedDate;

   @Column(name="AcceptedDate")
   private Date acceptedDate;
   
   @Enumerated
   @Column(name="LockStatus")
   private LockStatus lockStatus;

   @Column(name="HasPrivated")
   private Boolean hasPrivated;
   
   @Column(name = "CREATED_USER")
   private String createdUser;

   @Column(name = "CREATED_DATE")
   private Date createdDate;

   @Column(name = "MODIFYED_USER")
   private String modifyedUser;

   @Column(name = "MODIFYED_DATE")
   private Date modifyedDate;

   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public Participant getParticipant() {
      return participant;
   }

   public void setParticipant(Participant participant) {
      this.participant = participant;
   }

   public Date getRequestedDate() {
      return requestedDate;
   }

   public void setRequestedDate(Date requestedDate) {
      this.requestedDate = requestedDate;
   }

   public Date getAcceptedDate() {
      return acceptedDate;
   }

   public void setAcceptedDate(Date acceptedDate) {
      this.acceptedDate = acceptedDate;
   }

   public LockStatus getLockStatus() {
      return lockStatus;
   }

   public void setLockStatus(LockStatus lockStatus) {
      this.lockStatus = lockStatus;
   }

   public String getCreatedUser() {
      return createdUser;
   }

   public void setCreatedUser(String createdUser) {
      this.createdUser = createdUser;
   }

   public Date getCreatedDate() {
      return createdDate;
   }

   public void setCreatedDate(Date createdDate) {
      this.createdDate = createdDate;
   }

   public String getModifyedUser() {
      return modifyedUser;
   }

   public void setModifyedUser(String modifyedUser) {
      this.modifyedUser = modifyedUser;
   }

   public Date getModifyedDate() {
      return modifyedDate;
   }

   public void setModifyedDate(Date modifyedDate) {
      this.modifyedDate = modifyedDate;
   }

   public Boolean getHasPrivated() {
      return hasPrivated;
   }

   public void setHasPrivated(Boolean hasPrivated) {
      this.hasPrivated = hasPrivated;
   }

   public Participant getFriendInfo() {
      return friendInfo;
   }

   public void setFriendInfo(Participant friendInfo) {
      this.friendInfo = friendInfo;
   }

   public Friend clone(){
      Friend friend = new Friend();
      friend.setAcceptedDate(this.acceptedDate);
      friend.setCreatedDate(this.createdDate);
      friend.setCreatedUser(this.createdUser);
      friend.setModifyedDate(this.modifyedDate);
      friend.setModifyedUser(this.modifyedUser);
      friend.setRequestedDate(this.requestedDate);
      friend.setLockStatus(this.lockStatus);
      return friend;
   }

   @Override
   public boolean equals(Object obj) {
      Friend objectCompare = (Friend) obj;
      if (this.getId().longValue() == objectCompare.getId().longValue()) {
         return true;
      }
      return false;
   }
}

